﻿using System;
using System.Collections.Generic;
using System.Text;

namespace IceDog.DNL.CSharp.DesignPattern.TransferObjectPattern.StudentService
{
    public class StudentBO
    {
        //列表是当作一个数据库
        List<StudentVO> _students;

        public StudentBO()
        {
            _students = new List<StudentVO>();
            StudentVO student1 = new StudentVO("Robert", 0);
            StudentVO student2 = new StudentVO("John", 1);
            _students.Add(student1);
            _students.Add(student2);
        }
        public void DeleteStudent(StudentVO student)
        {
            _students.Remove(student);
        }

        //从数据库中检索学生名单
        public List<StudentVO> GetAllStudents()
        {
            return _students;
        }

        public StudentVO GetStudent(int rollNo)
        {
            return _students.Find(s => s.RollNo == rollNo);
        }

        public void UpdateStudent(StudentVO student)
        {
            var s = GetStudent(student.RollNo);
            s = student;
        }
    }
}
